package com.ming.controller;

import com.ming.common.Result;
import com.ming.common.validator.ValidatorUtil;
import com.ming.domain.Book;
import com.ming.from.BookForm;
import com.ming.query.BookQuery;
import com.ming.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:何元才
 * @Desc:
 * @data:2021-04-18 21:56
 */
@RestController
@RequestMapping("book")
public class BookController {

    @Autowired
    private BookService bookService;


    /**
     * 分页查询
     * @param query
     * @return
     */
    @GetMapping("page.do")
    public Object page(BookQuery query) {
        Result rs = bookService.queryPage(query);
        return rs;
    }

    /**
     * 新增
     * @param form
     * @return
     */
    @RequestMapping("add.do")
    public Object add(BookForm form) {
        ValidatorUtil.validator(form);
        Result rs = bookService.add(form);
        return rs;
    }

    /**
     * 删除
     * @param bookId
     * @return
     */
    @GetMapping("delete.do")
    public Object del(Integer bookId) {
        ValidatorUtil.validator(bookId);
        Result rs = bookService.del(bookId);
        return rs;
    }

    /**
     * 检查入库
     * @param bookId
     * @return
     */
    @GetMapping("check.do")
    public Object check(Integer bookId) {
        Result rs = bookService.check(bookId);
        return rs;
    }

}
